Page 75 - 2629_Devagiri_C-8
P. 75
Data Type Description Example Operator Description
Stores date and time values in YYYY-MM- created_at TIMESTAMP; < Checks if the left value is less than the right value.
TIMESTAMP
DD HH:MM:SS format. Example: ‘2025-07-10 14:30:00’
> Checks if the left value is greater than the right value.
is_active BOOLEAN;
BOOLEAN Stores TRUE or FALSE values. <= Checks if the left value is less than or equal to the right value.
Example: TRUE, FALSE
>= Checks if the left value is greater than or equal to the right value.
LOGICAL OPERATORS
CHAR data type always takes the same space, while VARCHAR data type only uses space for Logical operators are used to combine multiple conditions in a query. These operators allow
the characters you type.
you to create complex queries. They include the following types:
Operator Description
AND Returns TRUE if both conditions are true.
SQL OPERATORS
OR Returns TRUE if at least one condition is true.
SQL operators are used to perform operations on values in a SQL query. They enable access, Reverses the logical state of its operand, returning TRUE if the
comparison and modification of data in various ways. NOT condition is FALSE and vice versa.
Some common types of operators in SQL are:
Arithmetic operators Comparison operators SPECIAL OPERATORS
Some special operators in SQL are as follows:
Logical operators Special operators
Operator Description
ARITHMETIC OPERATORS
ALL Returns TRUE if all of the subquery values meet the condition.
Arithmetic operators perform basic mathematical operations on numerical data. They include
the following types: ANY Returns TRUE if any of the subquery values meet the condition.
Used to indicate a range which otherwise is done using relational
Operator Description BETWEEN
operators.
+ (Addition) Adds two values.
EXISTS Returns TRUE if the subquery returns one or more records.
- (Subtraction) Subtracts one value from another.
* (Multiplication) Multiplies two values.
/ (Division) Divides one value by another.
SQL CONSTRAINTS
% (Modulus) Returns the remainder when one value is divided by another.
SQL constraints are used to define rules for table data. These rules control the data that
COMPARISON OPERATORS can be stored in a column. Constraints are used to restrict the types of data that can be entered
Comparison operators are used to compare two expressions or values. They help in filtering into a table.
data based on conditions. They include the following types: Some different types of constraints include:
Operator Description NULL constraint: The NULL constraint allows a column to store NULL values. If no value is
= Checks if two values are equal. provided during insert or update, it does not cause an error.
!= or <> Checks if two values are not equal. NOT NULL constraint: The NOT NULL constraint specifies that a column must have a value.
Records cannot be inserted or updated without providing a value for this column.
73
MySQL: My First Database

